FROM python:3.9-slim

WORKDIR /app


# Copy dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Pre-download the Hugging Face embedding model during Docker build phase
# so it is baked into the image and does not need internet to start
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2')"

# Copy source code and vector DB
COPY . .

# Set offline environment variables
ENV HF_HUB_OFFLINE=1
ENV TRANSFORMERS_OFFLINE=1
ENV RAG_PORT=5002

EXPOSE 5002

CMD ["python", "rag_service.py"]
